<template>
  <el-form
    ref="form"
    :model="form"
    label-width="80px"
    style="max-width:300px;margin:10px auto;border:1px dashed darkgray;padding:10px 100px"
  >
    <el-form-item label="商家ID:">
      <el-input v-model="form._id" ></el-input>
    </el-form-item>
    <el-form-item label="商家账号:">
      <el-input v-model="form.merchantName"></el-input>
    </el-form-item>
    <el-form-item label="商家昵称:">
      <el-input v-model="form.merchantSusuper"></el-input>
    </el-form-item>
    <el-form-item label="商家电话:">
      <el-input v-model="form.phone"></el-input>
    </el-form-item>
    <el-form-item label="是否冻结:">
      <el-radio-group v-model="form.bool">
        <el-radio label="冻结"></el-radio>
        <el-radio label="不冻结"></el-radio>
      </el-radio-group>
    </el-form-item>
    <el-form-item>
      <el-button @click="updataFreezeMerchant(form)">确定</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
const axios = require('axios')
export default {
  created(){
    this.getMerchantId(this.$route.params._id)
  },
  data() {
    return {
      form: {
        _id: "",
        merchantName: "",
        merchantSusuper: "",
        phone: "",
        bool: ""
      }
    };
  },
  methods: {
    async getMerchantId(_id){
      const {data}=await axios.get('/pAdmins/pAdminId',{params:{_id}})
      // .then(({data})=>{ 
        if(data[0].bool){
          data[0].bool = '不冻结'
        }else{
          data[0].bool = '冻结'
        }
        this.form = data[0]
      // })
    },
    updataFreezeMerchant(all){
      if(this.form.bool ==='不冻结' ){
          this.form.bool = true
        }else{
          this.form.bool = false
        }
      axios.post('/pAdmins/pAdminUpdate',all).then(({data})=>{
        this.$router.push('/admin/adminIndex/merchant')
      })
    }
  }
}
</script>

<style>

</style>